﻿using Stardust.ConfigCenterWeb.Code.Entities;
using Stardust.ConfigCenterWeb.Code.Repositories;
using Stardust.ConfigCenterWeb.Code.Repositories.Impl;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Stardust.ConfigCenterWeb.Code.Services
{
    public class ServiceContractService
    {
        public static ServiceContractService Instance = new ServiceContractService();
        IServiceContractRepository contractRepository = new ServiceContractRepository();



        public List<ServiceContract> GetContractsByNode(long serverNodeId)
        {
            return contractRepository.GetContractsByNode(serverNodeId);
        }

        public bool SaveContracts(List<ServiceContract> list)
        {
            if (list == null || list.Count == 0) return false;
            var nodeId = list.First().ServerNodeId;
            return contractRepository.SaveContracts(nodeId, list);
        }
    }
}